package cn.hdu.goods.book.service;

import cn.hdu.goods.book.dao.BookDao;
import cn.hdu.goods.book.domain.Book;
import cn.hdu.goods.pager.PageBean;

import java.sql.SQLException;

public class BookService {
    private BookDao bookDao = new BookDao();

    public Book load(String bid) {
        try {
            return bookDao.findByBid(bid);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public PageBean<Book> findByCategory(String cid, int pc) {
        try {
            return bookDao.findByCategory(cid, pc);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public PageBean<Book> findByBname(String bname, int pc) {
        try {
            return bookDao.findByBname(bname, pc);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public PageBean<Book> findByAuthor(String author, int pc) {
        try {
            return bookDao.findByAuthor(author, pc);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public PageBean<Book> findByPress(String press, int pc) {
        try {
            return bookDao.findByPress(press, pc);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public PageBean<Book> findByCombination(Book criteria, int pc) {
        try {
            return bookDao.findByCombination(criteria, pc);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

}
